<?php
/**
 * Created by PhpStorm.
 * User: liyu
 * Date: 2018/4/9
 * Time: 下午2:18
 */

namespace app\common\service;


use think\Loader;

class Base
{
    public function checkParamIsNull($data)
    {
        $field = array_keys($data);
        if (empty($field))
            set_error_exception('params_not_null');
        return $field;
    }

    public function dbOperationResult($row)
    {
        if ($row > 0) {
            return true;
        } else {
            set_error_exception('db_error');
        }
    }

    /**
     * 快速调用执行model函数
     * @param $param_data
     * @param bool|false $validate_name
     * @param bool|false $model_name
     * @param string $action_name
     * @return array
     */
    protected function doModelAction($model_name, $action_name, $param_data, $map=[],$validate_field = false)
    {
        if ($validate_field != false) {
//
        }
        $model_edit = Loader::model($model_name,'model',false,'api');
        return $model_edit->$action_name($param_data);
    }
}